//
//  MessageContentCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/23.
//  Copyright © 2020 tym. All rights reserved.
//

#import "MessageContentCell.h"
#import "UIView+ZFFrame.h"
#import "UILabel+HXExtension.h"

@interface MessageContentCell ()

@property(nonatomic,weak) IBOutlet UIImageView *headIamge;
@property(nonatomic,weak) IBOutlet UILabel *titleLab;
@property(nonatomic,weak) IBOutlet UILabel *timeLab;

@property(nonatomic,weak) IBOutlet TYMLabel *contLab;
@end

@implementation MessageContentCell

-(void)awakeFromNib{
    [super awakeFromNib];
    self.contLab.zf_width = ScreenWidth - 30;
    self.contLab.textInsets = UIEdgeInsetsMake(15.f, 10.f, 15.f, 10.f);
}


-(void)layoutIfNeeded{
    self.contLab.zf_height = 90;
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.contLab.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
           CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
           maskLayer.frame = self.contLab.bounds;
           maskLayer.path = maskPath.CGPath;
           self.contLab.layer.mask = maskLayer;
}

+ (CGFloat)cellHeightWithModel:(id)model{
    
    UserMessageModel *messageModel = model;
    
    CGFloat height = [UILabel hx_getTextHeightWithText:messageModel.newsContent  width:ScreenWidth - 60 font:Font_Medium(13)];
    
    return 120+height;
}

+ (NSString *)identifier{
    return @"MessageCell";
}

-(void)setUserModel:(UserMessageModel *)userModel{
    
    if (userModel.type == 1) {
        self.headIamge.image = [UIImage imageNamed:@"icon_xitong"];
    }else if(userModel.type == 2){
        self.headIamge.image = [UIImage imageNamed:@"icon_jiating"];
    }else if(userModel.type == 3){
        self.headIamge.image = [UIImage imageNamed:@"icon／shebei"];
    }else if(userModel.type == 4){
        self.headIamge.image = [UIImage imageNamed:@"icon_kefu"];
    }
    
    self.titleLab.text = userModel.newsTitle;
    self.timeLab.text = [userModel.createTime substringWithRange:NSMakeRange(11, 5)];
    self.contLab.text = userModel.newsContent;
}


@end
